home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / CRS / crs32.d81 / examples.arc / GOTO.A < prev    next >
Text File  |  1989-12-01  |  3KB  |  88 lines

  1. ;goto.asm
  2. ;=================================
  3. ; Batch file command:  goto label
  4. ;=================================
  5. ; Example:
  6.                                   
  7. ;   goto there
  8. ;   dir/w
  9. ;   :there
  10. ;   dir
  11.                                   
  12.                                   
  13.                                   
  14. ndx         = $00d0               
  15. int04       = $1704               
  16. int05       = $1705               
  17. int0e       = $170e               
  18. int21       = $1721               
  19. stk1        = $1bd1               
  20. rdila       = $1bfa               
  21. primm       = $ff7d               
  22.                                   
  23. star        = $0b00               
  24.             .wor star             
  25.             * = star              
  26.                                   
  27.             jmp goto
  28.             dw  Date
  29.  
  30. goto        ldx #1                
  31.             jsr int04             ; label there?
  32.             bcc gt0               ; yep
  33. exit        ldx stk1              ; no. must be a BASIC GOTO
  34.             txs                   
  35.             lda #$40              
  36.             sta $ff00             
  37.             rts                   
  38.                                   
  39. gt0         cmp #"1"              ; if line number then let BASIC handle the goto
  40.             bcc gt00              
  41.             cmp #":"              
  42.             bcc exit              
  43. gt00        ldx #0                ; fetch label to go to
  44. gt1         sta $1b20,x           
  45.             inx                   
  46.             jsr int05             
  47.             bcc gt1               
  48.             stx lablen            ; save label length
  49.             bit rdila             ; in an exec file?
  50.             bpl noexec            ; no..quit
  51. gt2         jsr execin            ; get char from exec file
  52.             cmp #":"              ; is next line a label?
  53.             bne skpcr             ; no. skip ahead to CR
  54.             ldx #0                
  55. gt3         jsr execin            ; check one char
  56.             cmp $1b20,x           
  57.             bne skpcr             ; no match...skip this line
  58.             inx                   
  59.             cpx lablen            ; keep going until all chars checked
  60.             bne gt3               
  61.             jsr execin            ; line must end with a CR
  62.             cmp #13               
  63.             bne skpcr             
  64. ;           lda #0
  65. ;           sta ndx
  66. noexec      jmp int0e             ; found label. return
  67.                                   
  68. skpcr       cmp #13               ; skip line
  69.             beq gt2               
  70.             jsr execin            
  71.             jmp skpcr             
  72.                                   
  73. execin      ldy #9                ; int21 function 9 fetches char from exec file
  74.             lda #0                
  75.             jsr int21             
  76.             bcc eiok              ; ok
  77.             cmp #13               
  78.             beq eiok              ; maybe ok
  79. ;           jsr primm
  80. ;           .asc 13,"Goto failed...end of EXEC file reached",13,0
  81.             jmp int0e             
  82.                                   
  83. eiok        rts                   
  84.                                   
  85. lablen      .byt 0                
  86.                                   
  87.             .end                  
  88.